package com.king.time.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;

public class DateInfoUtils {

//    您的秘钥信息如下：
//    app_id:skgsrtrlst89tfjl
//    app_secret:UXhiazBRNzh6OXU3WTFuSnIzY2QxZz09
    public static void main(String[] args) throws Exception {
        StringBuilder inputLine = new StringBuilder();
        String read;

        URLConnection urlConnection = new URL("https://www.mxnzp.com/api/holiday/list/year/2022?ignoreHoliday=false&app_id=skgsrtrlst89tfjl&app_secret=UXhiazBRNzh6OXU3WTFuSnIzY2QxZz09").openConnection();
        urlConnection.setReadTimeout(30 * 1000);
        urlConnection.setConnectTimeout(30 * 1000);
        urlConnection.setRequestProperty("Charset", "UTF-8");
//        urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36)");
        BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), StandardCharsets.UTF_8));
        while ((read = in.readLine()) != null) {
            inputLine.append(read);
        }
        in.close();
        System.out.println(inputLine.toString());
    }
}
